#!/bin/sh -e
#
# zzz-bootstrap
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

BOOTSTRAP_WORK_DIR=/etc/kpc

bootstrap_file="$BOOTSTRAP_WORK_DIR/bootstrap.sh"
bootstrap_bak="${bootstrap_file}_bak"
bootstrap_done="${bootstrap_file}_done"
bootstrap_lock="${bootstrap_file}_lock"

if [ -x $bootstrap_file ]; then
  if [ -f $bootstrap_done ]; then
    mv -f $bootstrap_file $bootstrap_bak
  else
    (flock -x $bootstrap_lock -c "$bootstrap_file")&
  fi
fi

exit 0
